/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metro.jme.lottery.graphics.screens;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import metro.jme.lottery.business.XmlLoader;
import metro.jme.lottery.main.LotteryMIDlet;

/**
 *
 * @author pierre
 */
public class EditURLForm extends Form implements CommandListener {
	
	private NumberCanvas m_numberCanvas;
	private LotteryMIDlet m_MIDlet;
	private Command m_backCmd;
	
	public EditURLForm(MIDlet m, Canvas c) {
		super("Edit URL");
		m_numberCanvas = (NumberCanvas) c;
		m_MIDlet = (LotteryMIDlet) m;
		m_backCmd = new Command("Back", Command.BACK, 1);
		this.addCommand(m_backCmd);
		
		// add form element
		init();
	}
	
	private void init() {
		TextField tf = new TextField("URL", XmlLoader.URL, 1024, TextField.URL);
		this.append(tf);
	}

	public void commandAction(Command cmnd, Displayable dsplbl) {
		if(cmnd == m_backCmd) {
			m_MIDlet.displayNewScreen(m_numberCanvas);
			try {
				m_numberCanvas.init();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			m_numberCanvas.start();
			m_numberCanvas.setCommandListener(m_numberCanvas);
		}
	}
	
	
	
}
